package com.common.utils;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.util.Log;

import com.common.base.BaseApplication;

import java.io.File;


/**
 * 公共方法
 */
public class MethodUtils {


    public static String appFilePath(Context context) {
        String packageName = "com.ctaa"; // 应用程序的包名
        PackageManager packageManager = context.getPackageManager();
        String appPath = null;
        try {
            ApplicationInfo applicationInfo = packageManager.getApplicationInfo(packageName, 0);
            appPath = applicationInfo.sourceDir;
            Log.d("App Path", appPath);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        return appPath;
    }


    // 获取 files 目录（用于持久化文件）
    public static String getFilesDir() {
        File filesDir = BaseApplication.getAppContext().getFilesDir();
        String absolutePath = filesDir.getAbsolutePath();
        return absolutePath;
    }
}
